import { createRouter, createWebHashHistory } from 'vue-router';

const routes = [
  // 使用 routes 而不是 routers
  {
    path: '/',
    name: 'main',
    component: () => import('../pages/Main.vue'), // 修正 component 拼写
    redirect: '/home',
    children: [
      {
        name: 'home',
        path: '/home',
        component: () => import('../pages/Home.vue'), // 确保有对应的组件
      },
      {
        name: 'taskSelect',
        path: '/task/taskSelect',
        component: () => import('../pages/task/taskSelect.vue'),
      },
      {
        name: 'taskCheck',
        path: '/task/taskCheck',
        component: () => import('../pages/task/taskCheck.vue'),
      },
      {
        name: 'volunteerContorl',
        path: '/userContorl/volunteer',
        component: () => import('../pages/userControl/volunteer.vue'),
      },
      {
        name: 'elderlyContorl',
        path: '/userContorl/elderly',
        component: () => import('../pages/userControl/elderly.vue'),
      },

    ],
  },
  {
    path: '/user',
    name: 'person',
    component: () => import('../pages/admin/person.vue'),
  },
  {
    name: 'dataAnalyze',
    path: '/DataAnalyze',
    component: () => import('../pages/dataAnalyze/summary.vue'),

  },
  {
    name: 'elderlyAnalyze',
    path: '/DataAnalyze/elderlyAnalyze', // 显式定义完整路径
    component: () => import('../pages/dataAnalyze/elderlyAnalyze.vue'),
  },
  {
    name: 'volunteerAnalyze',
    path: '/DataAnalyze/volunteerAnalyze', // 显式定义完整路径
    component: () => import('../pages/dataAnalyze/volunteerAnalyze.vue'),
  },
  {
    name: 'taskAnalyze',
    path: '/DataAnalyze/taskAnalyze', // 显式定义完整路径
    component: () => import('../pages/dataAnalyze/TaskAnalyze.vue'),
  }
];

const router = createRouter({
  history: createWebHashHistory(), // 设置路由模式
  routes, // 使用 routes 配置项
});

export default router;
